package controller.stem;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.stems.StemsModel;
import model.stems.StemsModelInterface;

import valueObject.stem.Stem;




/**
 * Carrega os Stems do banco de dados e envia a lista para o View de Stems.
 * @author Luis Gabriel de Melo Fernandes
 *
 */
public class StemsViewController extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 546120900021246727L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException, ServletException {
		//
		StemsModelInterface stemsModel = new StemsModel();
		List<Stem> stems = stemsModel.getSteams(); 
				
		request.setAttribute("stems", stems);

		// Envia para o jsp do view da classe
		RequestDispatcher view = request.getRequestDispatcher("/stems/StemsView.jsp");
		view.forward(request, response);
	}
}